# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
# This source file is part of the Cangjie project, licensed under Apache-2.0
# with Runtime Library Exception.
#
# See https://cangjie-lang.cn/pages/LICENSE for license information.

from os import path

integer_types = ['Int8', 'Int16', 'Int32', 'Int64', 'UInt8', 'UInt16', 'UInt32', 'UInt64']
other_types = ['Float16', 'Float32', 'Float64', 'String', 'Rune', 'Bool', 'Unit', '(Int8, Int8)', 'Array<Int8>', 'Range<Int8>', 'Nothing']
types = integer_types + other_types
dir = path.dirname(path.realpath(__file__))
path = dir + '/test_' + path.basename(dir) + '_{}.cj'
template = '''
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
 * This source file is part of the Cangjie project, licensed under Apache-2.0
 * with Runtime Library Exception.
 *
 * See https://cangjie-lang.cn/pages/LICENSE for license information.
 */

/*
  @Assertion:   10.2.3(16) 3. The Cangjie programming language does not support user-defined operators. That is, it
                is not allowed to define operator functions with names other than operators listed in the above table.
  @Description: Checks that `{op}` cannot be overloaded.
  @Mode: compileonly
  @Negative: yes
  @Structure: single
  @CompileWarning: ignore
  @Comment: Auto-generated by gen.py
*/

class C {{
    operator func {op}() {{ }}
}}

main() {{ }}
'''
counter = 1

def write_counted(contents : str):
  global counter
  with open(path.format(str(counter).zfill(2)), 'w') as file:
    file.write(contents)
    counter += 1

custom_ops = list(',()[]{}') + '-> <- => ... # _ <: \\ $ ` " """ ${ 1 sampleIdentifier'.split() + types
for test in [template.format(op=op) for op in custom_ops]:
  write_counted(test)
